package com.shujia.sink

import org.apache.flink.streaming.api.functions.sink.PrintSinkFunction
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}

object Demo2PrintSink {
  def main(args: Array[String]): Unit = {
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    val socketDS: DataStream[String] = env.socketTextStream("master", 8888)

    /**
      * 打印出来
      *
      */

    val sink = new PrintSinkFunction[String]()

    socketDS.addSink(sink)

    //简写
    //socketDS.print()

    env.execute()
  }

}
